﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using MiragePWF.NH.Validation;
using Wolfut.MirageEE.Domain.CommonUtilities;
using Wolfut.MirageEE.Kernal.Common;

namespace Wolfut.MirageEE.Domain.Procurement
{
    [ActiveRecord]
    public class Supplier : PersistentObjectWithGuid
    {
        [Property("SUPPLIERS_CODE")]
        [ValidateIsUniqueInSameTransactionWithString(false, "数据库已经存在相同的供应商编号！")]
        [ValidateNonEmpty, ValidateLength(0, 100, "供应商编号超长！")]
        public virtual string SupplierCode
        {
            get { return supplierCode; }
            set { supplierCode = value; }
        }

        private string supplierCode;

        [Property("SUPPLIERS_TYPE")]
        public virtual SupplierType SupplierType
        {
            get { return supplierType; }
            set { supplierType = value; }
        }

        private SupplierType supplierType;

        [Property("SUPPLIERS_NAME")]
        [ValidateIsUniqueInSameTransactionWithString(false, "数据库已经存在相同的供应商名称！")]
        [ValidateNonEmpty, ValidateLength(0, 200, "供应商名称超长！")]
        public virtual string SupplierName
        {
            get { return supplierName; }
            set { supplierName = value; }
        }

        private string supplierName;

        [Property("SUPPLIERS_SOURCE")]
        public virtual SupplierSource SupplierSource
        {
            get { return supplierSource; }
            set { supplierSource = value; }
        }

        private SupplierSource supplierSource;

        [Property("AREA_CODE")]
        public virtual string AreaCode
        {
            get { return areaCode; }
            set { areaCode = value; }
        }

        private string areaCode;

        [Property("SUPPLIERS_CATEGORY")]
        public virtual string SupplierCategory
        {
            get { return supplierCategory; }
            set { supplierCategory = value; }
        }

        private string supplierCategory;

        [Property("SALES_MAN")]
        public virtual string Salesman
        {
            get { return salesman; }
            set { salesman = value; }
        }

        private string salesman;

        [Property]
        public virtual string Remarks
        {
            get { return remarks; }
            set { remarks = value; }
        }

        private string remarks;

        [Property("PAYMENT_METHODS")]
        public virtual string PaymentMethods
        {
            get { return paymentMethods; }
            set { paymentMethods = value; }
        }

        private string paymentMethods;


        [Property("DISCOUNT_RATE")]
        [ValidateRange(0, 100, "折扣率必须在0到100之间！")]
        public virtual decimal DiscountRate
        {
            get { return discountRate; }
            set { discountRate = value; }
        }

        private decimal discountRate;

        [Property("CLOSING_PERIOD")]
        [ValidateRange(0, int.MaxValue, "不合法的帐期！")]
        public virtual int ClosingPeriod
        {
            get { return closingPeriod; }
            set { closingPeriod = value; }
        }

        private int closingPeriod;

        [Property]
        [ValidateRange(0, int.MaxValue, "不合法的信用额度！")]
        public virtual decimal Credits
        {
            get { return credits; }
            set { credits = value; }
        }

        private decimal credits;

        [Property("DEFAULT_TAX_RATE")]
        [ValidateRange(0, 100, "不合法的税率！")]
        public virtual decimal DefaultTaxRate
        {
            get { return defaultTaxRate; }
            set { defaultTaxRate = value; }
        }

        private decimal defaultTaxRate;


        [Property("IS_DELETED")]
        public virtual bool IsDeleted
        {
            get { return isDeleted; }
            set { isDeleted = value; }
        }

        private bool isDeleted;
    }
}